<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>纯css点击切换方法二</title>
    <style>
        .box{
            width: 300px;
            height: 300px;
            border: 1px solid #000;
            text-align: center;
            margin: 0 auto;
            position: relative;
            top: 100px;
        }
        nav{
            width: 300px;
            height: 50px;
            border-bottom: 1px solid #000;
        }
        nav a{
            display: block;
            text-decoration: none;    
            float: left;
            margin: 0 1px;
            width: 98px;
            height: 50px;
            background-color: aqua;
            line-height: 50px;
        }
        .content{
            width: 300px;
            height: 249px;
            /* overflow: hidden; */
            position: relative;
        }
        .cont{
            width: 300px;
            height: 249px;
            text-align: center;
            line-height: 249px;
            font-size: 30px;
            position: absolute;
            color: white;
        }
        #one{
            z-index: 1;
            background-color: rosybrown;
        }
        #two{
            background-color: red;
        }
        #three{
            background-color: aquamarine;
        }
        #one:target, #two:target, #three:target{
            /* target 选中的是当前被链接到的目标元素，target 伪类是加在目标元素上，而不是点击元素上 */
            z-index: 9;
        }
    </style>
</head>

<body>
    <div class="box">
        <nav>
            <a href="#one">按钮1</a>
            <a href="#two">按钮2</a>
            <a href="#three">按钮3</a>
        </nav>
        <div class="content">
            <div class="cont" id="one">内容1</div>
            <div class="cont" id="two">内容2</div>
            <div class="cont" id="three">内容3</div>
        </div>
    </div>
</body>

</html>